package capricornus.net
{
	import capricornus.core.StageManager;
	
	import flash.display.Stage;
	import flash.system.ApplicationDomain;
	import flash.system.LoaderContext;
	import flash.system.SecurityDomain;

	public class NetWorkManager
	{
		private static var _ins:NetWorkManager = null;
		
		private var _isNetWork:Boolean = false;
		private var _loaderContext:LoaderContext;
		
		private var _stage:Stage;
		
		public function NetWorkManager()
		{
		}
		
		public static function get instance():NetWorkManager
		{
			if( null==_ins )
			{
				_ins = new NetWorkManager();
			}
			return _ins;
		}
		
		public function initialize():void
		{
			_stage = StageManager.stage;
			
			_isNetWork = !(_stage.loaderInfo.url.indexOf( "file://" )==0);
			_loaderContext = new LoaderContext( false, ApplicationDomain.currentDomain, _isNetWork?SecurityDomain.currentDomain:null );
		}
		
		public function get isNetWork():Boolean
		{
			return _isNetWork;
		}
		
		public function get loaderContext():LoaderContext
		{
			return _loaderContext;
		}
	}
}